var roleHar_o = {

    /** @param {Creep} creep **/
    run: function(creep) {
	    creep.say('o');
	   // if(creep.store.getFreeCapacity() > 0) {
    //         var sources = creep.room.find(FIND_MINERALS);
    //         if(creep.harvest(sources[0]) == ERR_NOT_IN_RANGE) {
    //             creep.moveTo(sources[0], {visualizePathStyle: {stroke: '#ffaa00'}});
    //         }
    //     }
    //     else {
    //         var targets = creep.room.find(FIND_STRUCTURES, {
    //                 filter: (structure) => {
    //                     return (structure.structureType == STRUCTURE_TERMINAL) && 
    //                             structure.store.getFreeCapacity() > 0;
    //                 }
    //         });
    //         if(targets.length > 0) {
    //             if(creep.transfer(targets[0],RESOURCE_OXYGEN ) == ERR_NOT_IN_RANGE) {
    //                 creep.moveTo(targets[0], {visualizePathStyle: {stroke: '#ffffff'}});
    //             }
    //         }
    //     }
    //物流模式
        
        var targetsgo = creep.room.find(FIND_STRUCTURES, {
                filter: (structure) => {
                    return structure.structureType == STRUCTURE_CONTAINER;
                }
        });
        if(targetsgo.length > 0) {
                creep.moveTo(targetsgo[0]);
                //creep.say('采去');
                if(creep.pos.isEqualTo(targetsgo[0].pos)){
                    const target = creep.pos.findClosestByRange(FIND_MINERALS);
                    if(target) {
                        creep.harvest(target);
                        //creep.say('开采');
                    }
                }
        }
	}
};

module.exports = roleHar_o;